package cn.hs.ph.dao.impl;

import cn.hs.ph.entity.User;
import cn.hs.ph.util.JDBCDruidUtil;

import java.sql.ResultSet;
import java.sql.SQLException;

public class UserDaoimpl implements cn.hs.ph.dao.UserDao {
    @Override
    public User selectByUsernameAndPwd(String username, String pwd) throws SQLException {
        String sql = "select * from user where username=? and pwd=?";
        Object[] obj = {username, pwd};
        User user = null;
        ResultSet query = JDBCDruidUtil.query(sql, obj);
        if (query.next()) {
           user = new User(query.getInt(1), query.getString(2), query.getString(3));
        }
        return user;


    }
}
